/*  header-comment
/*  file   : /Users/allan/Desktop/workSpace/react-hrm-h5/src/modules/hrCenter/footerBar/index
/*  author : Allan
/*  date   : 2017-6-4 18:24:50
/*  last   : 2017-11-0 14:49:2
*/
import React, { Component } from "react";
import { Link, IndexLink } from "react-router";
import autobind from "autobind-decorator";
import { get, set } from "../../../utils/db";
import PropTypes from "prop-types";
// import { openLink } from "../../../utils/dingtalk";
import "./index.less";

export default class FooterBar extends Component {

  @autobind
  setUserId(event) {
    //避免频繁 渲染
    const hash = window.location.hash;
    if (hash && hash.toLocaleLowerCase().indexOf("personalcenter") !== -1) {
      event.preventDefault();// 已经调到【我的】阻止路由渲染
    }
    set("userId", get("currentUserId"));
  }

  render() {

    const { hasWeekly, hasPermission, show } = this.props;
    this.props.userId && set("param:userId", this.props.userId);

    if (!show) return null;
    return (
      <div className="footer-bar scroll-btn">

        {//有人事管理权限
          hasPermission ? <div>

            {
              <Link
                className={hasWeekly ? "col4" : "col3"}
                activeClassName="active"
                to="/hrcenter/manage">
                <i className="icon-1" />
                <p>管理</p>
              </Link>
            }
            {
              hasWeekly &&
              <Link
                className="col4"
                activeClassName="active"
                to={'/hrcenter/employeeAnalyze'}
              >
                <i className="icon-0" />
                <p>人事报表</p>
              </Link>
            }
            <Link
              to="/hrcenter/selfHelp"
              activeClassName="active"
              className={hasWeekly ? "col4" : "col3"}>
              <i className="icon-3" />
              <p>自助服务</p>
            </Link>
            <Link
              to="/hrcenter/personalCenter"
              activeClassName="active"
              className={hasWeekly ? "col4" : "col3"}
              onClick={this.setUserId}>
              <i className="icon-4" />
              <p>我的</p>
            </Link>
          </div> : ""
        }

        {//没有人事管理权限的
          !hasPermission ? <div>
            <Link
              to="/hrcenter/selfHelp"
              activeClassName="active"
              className='col2'>
              <i className="icon-3" />
              <p>自助服务</p>
            </Link>
            <Link
              to="/hrcenter/personalCenter"
              activeClassName="active"
              className='col2'
              onClick={this.setUserId}>
              <i className="icon-4" />
              <p>我的</p>
            </Link>
          </div> : ""
        }
      
      </div>
    );
  }
}
